package com.pi.model;

public class BaseResult<T> {
    private int code;
    private String message;
    private T data;

    public BaseResult(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;

    }

    public BaseResult(int code, String message) {
        this.code = code;
        this.message = message;

    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static <T> BaseResult<T> success(T data) {
        return new BaseResult<>(200, "success", data);
    }

    public static <T> BaseResult<T> success() {
        return new BaseResult<>(200, "success");
    }

    public static <T> BaseResult<T> fail(int code, String message) {
        return new BaseResult<>(code, message);
    }

    public static <T> BaseResult<T> fail(String message) {
        return new BaseResult<>(500, message);
    }

    public static <T> BaseResult<T> fail() {
        return new BaseResult<>(500, "fail");
    }

    public static <T> BaseResult<T> fail(T data) {
        return new BaseResult<>(500, "fail", data);
    }

    public static <T> BaseResult<T> fail(int code, String message, T data) {
        return new BaseResult<>(code, message, data);
    }

}
